// 统一管理首页模块接口
import request from '@/services/request';
import type { HospitalResDataInterface, IHospitalInfo, IHospitalLevelandReginData } from './type';

// 通过枚举管理首页模块的借口地址
enum API_HOME {
  // 获取已有的医院的数据接口地址
  HOSPITAL_URL = '/hosp/hospital/',
  // 获取医院的等级和地区
  HOSPITAL_LEVEL_REGIN_URL = '/cmn/dict/findByDictCode/',
  // 搜索 根据医院名称获取医院列表
  HOSPITAL_SEARCH_BY_NAME = '/hosp/hospital/findByHosname/',
}

// 获取医院的数据
export const reqHospitalList = (page: number, limit: number, hostype: string = '', districtCode: string = '') => {
  return request.get<any, HospitalResDataInterface>(
    API_HOME.HOSPITAL_URL + `${page}/${limit}?hostype=${hostype}&districtCode=${districtCode}`,
  );
};
// 获取医院的等级和地区/api/cmn/dict/findByDictCode/{dictCode}
export const reqHospitalLevelAndRegin = (dictCode: string) =>
  request.get<any, IHospitalLevelandReginData>(API_HOME.HOSPITAL_LEVEL_REGIN_URL + dictCode);
// 搜索 根据医院名称获取医院列表
export const reqSearchHospitalByName = (hosname: string) =>
  request.get<any, IHospitalInfo>(API_HOME.HOSPITAL_SEARCH_BY_NAME + `${hosname}`);
